package com.example.transactionhintassistant.controller;

import com.example.transactionhintassistant.pojo.dto.ringtone.AddRingtoneDto;
import com.example.transactionhintassistant.pojo.dto.ringtone.ChangeRingtoneDto;
import com.example.transactionhintassistant.pojo.vo.RingtoneVo;
import com.example.transactionhintassistant.service.RingtoneSelectionService;
import com.example.transactionhintassistant.service.RingtonesService;
import com.example.transactionhintassistant.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ringtone")
@Tag(name = "7.铃声模块")
public class RingtoneController {
    @Autowired
    private RingtonesService ringtonesService;
    @Autowired
    private RingtoneSelectionService ringtoneSelectionService;

    @GetMapping("/list")
    @Operation(summary = "获取所有铃声", security = {@SecurityRequirement(name = "Authorization")})
    public Result<List<RingtoneVo>> getAllRingtones() {
        return ringtonesService.getAllRingtones();
    }

    @PostMapping("/one")
    @Operation(summary = "添加铃声", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> addRingtone(@RequestBody @Validated AddRingtoneDto addRingtoneDto) {
        return ringtonesService.addRingtone(addRingtoneDto);
    }

    @PutMapping("/one")
    @Operation(summary = "修改铃声", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> changeRingtone(@RequestBody @Validated ChangeRingtoneDto changeRingtoneDto) {
        return ringtonesService.changeRingtone(changeRingtoneDto);
    }

    @DeleteMapping("/one/{id}")
    @Operation(summary = "删除铃声", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> deleteRingtone(@PathVariable Integer id) {
        return ringtonesService.deleteRingtone(id);
    }

    @PostMapping("/select/{id}")
    @Operation(summary = "添加铃声选择", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> addRingtoneSelection(@PathVariable Integer id) {
        return ringtoneSelectionService.addRingtoneSelection(id);
    }

    @PutMapping("/select/{id}")
    @Operation(summary = "更改铃声选择", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> changeRingtoneSelection(@PathVariable Integer id) {
        return ringtoneSelectionService.changeRingtoneSelection(id);
    }
}
